<?php
/**
 * 	Author: Niek Saarberg
 * 	Date:	22 oktober 2008
 * 
 */

class Settings {
	
	// object instance
    private static $instance;
    
    private static $settings;
    public static $library;
 
    private function __construct() {}
    private function __clone() {}
    
    public static function getInstance() {
    	
		if (!self::$instance instanceof self) {
            self::$instance = new self();
        }
        return self::$instance;	
    }
	
	public static function setIni($file) {
		
		#check if file exists
		if(!is_readable($file) == true) {
			
			throw new Exception('Ini file not found ' . $file);
		}
		
		#set ini vars in class
		self::$settings = parse_ini_file($file, true);
	}
	
	public static function get($key) {
		
		return self::$settings[$key];
	}
	
	/**
	 * Pad toevoegen waar libraries in zitten. Deze
	 * functie is alleen voor modules.
	 * 
	 * @access static
	 * @param string $path pad naam
	 * @return void
	 */
	public static function addLibraryPath($path) {
		
		$path = SITE_PATH . '_modules' . DIRSEP . $path . DIRSEP . 'library';
		
		if(is_dir($path) == false) {
			
			throw new Exception("Library path not found.");
		}
		
		self::$library[] = $path;
	}
}